package com.guli.generator.controller;

import com.guli.generator.mapper.EduSubjectMapper;
import com.guli.generator.pojo.EduSubject;
import com.guli.generator.service.EduSubjectService;
import com.guli.generator.subject.OneSubject;
import com.gulicom.R;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("eduservice/subject")
@CrossOrigin
public class EduSubjectController {
    @Resource
    private EduSubjectService subjectService;
    @Resource
    private EduSubjectMapper mapper;
    @PostMapping("/addSubject")
    public R goToSub(MultipartFile file){
        subjectService.saveSubject(file,mapper);
        return R.ok();
    }
    @GetMapping("/getAllSubject")
    public R getSub(){
        List<OneSubject> oneSubjects = subjectService.getEduSubject();
        if(oneSubjects!=null){
            return R.ok().data("list",oneSubjects);
        }
        return R.error();

    }
}
